package cn.demo.um.support.handler;

import cn.demo.um.domain.UmAttrData;
import cn.demo.um.support.handler.base.IBaseMatcherHandler;
import lombok.Data;

import java.util.List;
import java.util.Map;

@Data
public class MatcherHandlerWrapper {
    private Long sort;
    private String attrCode;
    private double score = 1;
    private IBaseMatcherHandler baseMatcherHandler;

    public MatcherHandlerWrapper(String attrCode, IBaseMatcherHandler baseMatcherHandler, Long sort) {
        this.attrCode = attrCode;
        this.baseMatcherHandler = baseMatcherHandler;
        this.sort = sort;
    }

    public void invoke(MatcherContext matcherContext) {
        baseMatcherHandler.handler(matcherContext, attrCode, score);
    }

    /**
     * 构建出这个处理器需要的倒排索引
     * @param umAttrDataList
     */
    public Object buildInvertedIndex(List<UmAttrData> umAttrDataList) {
        return baseMatcherHandler.buildInvertedIndex(umAttrDataList,attrCode);
    }
}
